<template>
  <!-- 确认框 -->
  <a-modal
    :title="title"
    :cancelText="cancelText"
    :okText="okText"
    v-model="visible"
    :destroyOnClose="true"
    @ok="handleOk"
  >
    <p class="confirm-tip">
      <a-icon type="info-circle" />
      <i>{{contentText}}</i>
    </p>
  </a-modal>
</template>

<script>
export default {
  name:'confirmModal',
  props: {
    hint: {
      required: false
    },
    okText: {
      type: String,
      default: '确认',
      required: false
    },
    cancelText: {
      type: String,
      default: '取消',
      required: false
    }
  },
  computed: {
    title () {
      if (this.hint === 5) {
        return '保存'
      } else if (this.hint === 6)  {
        return '删除'
      } else if (this.hint === 7)  {
        return '提交审核'
      } else {
        return '操作确认'
      }
    },
    contentText () {
      var confirmTxt = {
        '1': '是否确认开启分润，开启后该账号将获取收益！',
        '2': '是否确认关闭分润，关闭后该账号将无法获得收益！',
        '3': '是否确认开启账号，开启后该账号将被正常使用！',
        '4': '是否确认关闭账号，关闭后该账号将无法被使用！',
        '5': '是否确认保存',
        '6': '是否确认删除',
        '7': '是否确认提交审核',
        '8': '请确认是否上架'
      }
      return confirmTxt[this.hint]
    }
  },
  data () {
    return {
      visible: false
    }
  },
  methods: {
    // 打开弹窗
    openModal () {
      this.visible = true
    },
    handleOk () {
      this.$emit('handleConfirm', this.hint)
      this.visible = false
    }
  }
}
</script>

<style>

</style>
